package com.swf.seed.xml.jaxb;

import java.io.File;
import java.util.Date;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import com.swf.seed.base.SystemContants;
import com.swf.seed.xml.jaxb.monitor.MFile;
import com.swf.seed.xml.jaxb.monitor.MonitorManager;

public class JaxbTest {
	public static void main(String[] args) {
		MonitorManager monitor = new MonitorManager();
		MFile m = new MFile();
		m.setName("c");
		m.setTime(new Date());
		MFile m1 = new MFile();
		m1.setName("d");
		m1.setTime(new Date());
		MFile m3 = new MFile();
		m3.setName("d");
		m3.setTime(new Date());
		
		monitor.getFileMonitor().add(m);
		monitor.getFileMonitor().add(m1);
		monitor.getFileMonitor().add(m3);
		try {

			File file = new File(SystemContants.PROJECT_PATH, "customer.xml");
			JAXBContext jaxbContext = JAXBContext.newInstance(MonitorManager.class);
			Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
			// output pretty printed
			jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

		//	jaxbMarshaller.marshal(customer, file);
			jaxbMarshaller.marshal(monitor, System.out);

		} catch (JAXBException e) {
			e.printStackTrace();
		}

	}

}
